//package com.hsylient.translator;
//
//import okhttp3.*;
//
//import java.io.IOException;
//import java.net.InetSocketAddress;
//import java.net.Proxy;
//import java.net.http.HttpClient;
//import java.util.concurrent.TimeUnit;
//
//public class GPT4Example {
////    private final OkHttpClient httpClient = new OkHttpClient();
//
//    private static final String PROXY_HOST = "127.0.0.1";
//    private static final int PROXY_PORT = 7890;
//
//    public static void main(String[] args) throws Exception {
//        GPT4Example example = new GPT4Example();
//        example.sendPost();
//    }
//
//    private void sendPost() throws Exception {
//
//        OkHttpClient httpClient = new OkHttpClient.Builder()
//                .connectTimeout(5, TimeUnit.SECONDS)
//                .writeTimeout(150, TimeUnit.SECONDS)
//                .readTimeout(150, TimeUnit.SECONDS)
//                .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(PROXY_HOST, PROXY_PORT)))
//                .build();
//
//
//        // json request body
//        String json = "{\"prompt\":\"Translate 'Hello' to French\","
//                + "\"max_tokens\": 60}";
//
//        RequestBody body = RequestBody.create(
//                MediaType.parse("application/json; charset=utf-8"), json);
//
//        Request request = new Request.Builder()
//                .url("https://api.openai.com/v4/engines/davinci-codex/completions")
//                .addHeader("Authorization", "Bearer YOUR_OPENAI_KEY")
//                .post(body)
//                .build();
//
//        try (Response response = httpClient.newCall(request).execute()) {
//            if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
//
//            // Get response body
//            System.out.println(response.body().string());
//        }
//    }
//}
